﻿CREATE FUNCTION [dbo].[fs_StateID_Start]
( @TableName as sysname
)RETURNS int
AS
BEGIN

RETURN(
SELECT  TOP(1)  StateID
FROM         v_State_Group_Access SGA-- INNER JOIN UserGroups() UG ON SGA.principal_id = UG.principal_id
WHERE     (StateAccessID = 8) AND (TableName = @TableName)
ORDER BY StateFlowPos
)
END
